package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;
import com.lnking.lnkingplace.mapper.InspectTypeMapper;
import com.lnking.lnkingplace.model.request.inspect.inspectType.InspectTypeAddRequest;
import com.lnking.lnkingplace.model.request.inspect.inspectType.InspectTypeSearchRequest;
import com.lnking.lnkingplace.model.request.inspect.inspectType.InspectTypeUpdateRequest;
import com.lnking.lnkingplace.model.request.record.user.RecordUserSearchRequest;
import com.lnking.lnkingplace.service.IInspectTypeService;
import com.lnking.lnkingplace.service.IInspectTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sn
 * @since 2022-09-16
 */
@Api(tags = "检查类型")
@RestController
@RequestMapping("/inspect-type")
public class InspectTypeController {

    @Resource
    IInspectTypeService iInspectTypeService;
    @Resource
    InspectTypeMapper inspectTypeMapper;


    @PostMapping("add")
    @ApiOperation("新增")
    public ReturnResult add(@RequestBody InspectTypeAddRequest params){
        iInspectTypeService.add(params);
        return ReturnResult.success();
    }

    @PostMapping("update")
    @ApiOperation("修改")
    public ReturnResult update(@RequestBody InspectTypeUpdateRequest params){
        iInspectTypeService.update(params);
        return ReturnResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public ReturnResult update(@PathVariable("id") String id){
        iInspectTypeService.removeById(id);
        return ReturnResult.success();
    }

    @ApiOperation("查询列表")
    @GetMapping("/list")
    public ReturnResult getList(InspectTypeSearchRequest params) {
        return ReturnResult.success(iInspectTypeService.pageList(params));
    }

    @ApiOperation("查询除了当前数据外的列表")
    @GetMapping("/out/list")
    public ReturnResult getOutList(String rectificationId,String content,String classification) {
        return ReturnResult.success(iInspectTypeService.getOutList(rectificationId,content,classification));
    }

    @ApiOperation("得到指标类型")
    @GetMapping("/get-type")
    public ReturnResult getType(String type) {
        return ReturnResult.success(inspectTypeMapper.getType(type));
    }

    @ApiOperation("得到指标二级分类")
    @GetMapping("/get-classification")
    public ReturnResult getClassification() {
        return ReturnResult.success(inspectTypeMapper.getClassification());
    }


    @ApiOperation("获取指标详情")
    @GetMapping("/get-index")
    public ReturnResult getIndex(String name) {
        return ReturnResult.success(inspectTypeMapper.getIndex(name));
    }

}
